package com.springboot.test.web.app;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.springboot.test.common.enums.StaticKey;
import com.springboot.test.common.response.Response;
import com.springboot.test.service.VisitRecordService;
import com.springboot.test.service.param.pageparam.BasePageParam;
import com.springboot.test.service.result.VisitRecordResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("app/record")
public class RecordController {

    @Resource
    private VisitRecordService visitRecordService;

    @GetMapping("visit")
    public Response<Boolean> saveVisitRecord(@RequestParam String goodsCode,@RequestAttribute(StaticKey.USER_CODE) String userCode){
        visitRecordService.addVisitRecord(goodsCode,userCode);
        return Response.success(Boolean.TRUE);
    }

    @PostMapping("query_record")
    public Response<Page<VisitRecordResult>> recordPage(BasePageParam param, @RequestAttribute(StaticKey.USER_CODE)String userCode){
        return Response.success(visitRecordService.recordPage(param,userCode));
    }
}
